import React, { useState, useEffect } from 'react';
import { 
  Card, Form, Radio, Select, DatePicker, Button, 
  Table, Alert, Typography, Space, Pagination, Row, Col,
  Tabs, Modal, Input, Popconfirm, Divider, Collapse, ConfigProvider
} from 'antd';
import { 
  SearchOutlined, DatabaseOutlined, PlusOutlined, 
  ReloadOutlined, EditOutlined, DeleteOutlined 
} from '@ant-design/icons';
import { fetchStockCodes, fetchStockData, stockInfoApi, stockDataIntegrityApi, sync5mToRealgo5mApi } from '../../api';
import './index.css';
import moment from 'moment';
import zhCN from 'antd/es/locale/zh_CN';

const { Option } = Select;
const { Title, Text } = Typography;
const { RangePicker } = DatePicker;
const { TabPane } = Tabs;

const StockData = () => {
  const [form] = Form.useForm();
  const [stockInfoForm] = Form.useForm();
  
  const [stockData, setStockData] = useState({
    code: '',
    is_real: false,
    pagination: {
      page: 1,
      page_size: 10,
      total_records: 0,
      total_pages: 0
    },
    data: []
  });
  
  // 股票信息管理状态
  const [stockList, setStockList] = useState([]);
  const [stockInfoLoading, setStockInfoLoading] = useState(false);
  const [modalVisible, setModalVisible] = useState(false);
  const [editingStock, setEditingStock] = useState(null);
  
  const [loading, setLoading] = useState(false);
  const [error, setError] = useState(null);
  const [availableCodes, setAvailableCodes] = useState({
    history: [],
    real: []
  });
  
  // 查询参数
  const [queryParams, setQueryParams] = useState({
    code: '',
    is_real: false,
    start_date: '',
    end_date: '',
    page: 1,
    page_size: 100
  });

  // 在状态定义部分添加股票信息分页状态
  const [stockInfoPagination, setStockInfoPagination] = useState({
    current: 1,
    pageSize: 100,
    total: 0
  });

  const [integrityLoading, setIntegrityLoading] = useState(false);
  const [integrityData, setIntegrityData] = useState({ missing: [], duplicate: [], base_code: '', base_dates_count: 0 });
  const [integrityTab, setIntegrityTab] = useState('missing');
  const [integrityPage, setIntegrityPage] = useState(1);
  const [integrityPageSize, setIntegrityPageSize] = useState(50);
  const [integrityIsReal, setIntegrityIsReal] = useState(true);
  const [integrityStartDate, setIntegrityStartDate] = useState(null);

  // Collapse分组分页状态
  const [integrityMissingPageMap, setIntegrityMissingPageMap] = useState({});
  const [integrityDuplicatePageMap, setIntegrityDuplicatePageMap] = useState({});
  const PAGE_SIZE = 100;

  const [syncDate, setSyncDate] = useState(null);
  const [syncLoading, setSyncLoading] = useState(false);
  const [syncResult, setSyncResult] = useState(null);

  // 获取可用的股票代码
  useEffect(() => {
    const loadStockCodes = async () => {
      try {
        const data = await fetchStockCodes();
        setAvailableCodes(data || { history: [], real: [] });
        
        // 如果有可用的代码，默认选择第一个
        if (data && data.history && data.history.length > 0) {
          form.setFieldsValue({ 
            code: data.history[0], 
            is_real: false,
            page_size: 100
          });
          
          setQueryParams(prev => ({
            ...prev,
            code: data.history[0]
          }));
        }
      } catch (error) {
        console.error('Error fetching stock codes:', error);
        setError('获取股票代码失败');
      }
    };
    
    loadStockCodes();
  }, [form]);

  // 获取股票数据
  const fetchData = async (params = queryParams) => {
    if (!params.code) {
      setError('请选择股票代码');
      return;
    }
    
    setLoading(true);
    setError(null);
    
    try {
      // 构建查询参数
      const apiParams = {
        code: params.code,
        is_real: params.is_real,
        page: params.page,
        page_size: params.page_size
      };
      
      if (params.start_date) {
        apiParams.start_date = params.start_date;
      }
      
      if (params.end_date) {
        apiParams.end_date = params.end_date;
      }
      
      console.log('Fetching stock data with params:', apiParams);
      const data = await fetchStockData(apiParams);
      console.log('API Response type:', typeof data);
      console.log('API Response:', data);
      
      // 如果响应是字符串，尝试解析为 JSON
      if (typeof data === 'string') {
        try {
          const parsedData = JSON.parse(data);
          console.log('Parsed data:', parsedData);
          setStockData(parsedData);
        } catch (e) {
          console.error('Failed to parse response as JSON:', e);
          setError('API 返回的数据格式不正确');
        }
      } else {
        setStockData(data);
      }
    } catch (error) {
      console.error('Error fetching stock data:', error);
      setError(error.message || '获取数据失败');
    } finally {
      setLoading(false);
    }
  };

  // 表单提交
  const handleSubmit = (values) => {
    const { dateRange, ...rest } = values;
    
    const params = {
      ...rest,
      page: 1, // 重置为第一页
      start_date: dateRange?.[0]?.format('YYYY-MM-DD HH:mm:ss'),
      end_date: dateRange?.[1]?.format('YYYY-MM-DD HH:mm:ss'),
    };
    
    setQueryParams(params);
    
    // 更新页面查询参数后立即获取数据
    fetchData(params);
  };

  // 页码变化
  const handlePageChange = (page, pageSize) => {
    console.log('Page changed to:', page, 'pageSize:', pageSize);
    
    // 立即更新查询参数
    const newParams = {
      ...queryParams,
      page,
      page_size: pageSize
    };
    
    setQueryParams(newParams);
    
    // 使用最新的参数直接获取数据
    fetchData(newParams);
  };

  // 数据源类型改变时更新代码列表
  const handleDataSourceChange = (e) => {
    const isReal = e.target.value;
    form.setFieldsValue({ is_real: isReal });
    
    // 如果切换数据源后有可用代码，自动选择第一个
    const codes = isReal ? (availableCodes.real || []) : (availableCodes.history || []);
    if (codes.length > 0) {
      form.setFieldsValue({ code: codes[0] });
    } else {
      form.setFieldsValue({ code: undefined });
    }
  };

  // 动态表格列
  const generateColumns = () => {
    if (!stockData.data || !stockData.data.length) return [];
    
    const firstRow = stockData.data[0];
    return Object.keys(firstRow).map(key => ({
      title: key === 'date' ? '日期' : 
             key === 'close' ? '收盘价' : 
             key === 'code' ? '代码' : key,
      dataIndex: key,
      key: key,
      render: (text) => {
        // 处理 null 或 undefined 值
        if (text === null || text === undefined) return '-';
        return text;
      },
      sorter: key === 'date' ? (a, b) => moment(a.date).unix() - moment(b.date).unix() : 
              typeof firstRow[key] === 'number' ? (a, b) => {
                // 处理可能的 null 值
                const aVal = a[key] === null ? 0 : a[key];
                const bVal = b[key] === null ? 0 : b[key];
                return aVal - bVal;
              } : undefined,
    }));
  };

  // 股票信息管理相关函数
  // 获取所有股票信息
  const fetchStockInfo = async () => {
    setStockInfoLoading(true);
    try {
      const data = await stockInfoApi.getAllStockInfo();
      setStockList(data);
      setStockInfoPagination(prev => ({
        ...prev,
        total: data.length
      }));
    } catch (error) {
      console.error('获取股票信息失败:', error);
    } finally {
      setStockInfoLoading(false);
    }
  };

  // 初始化股票信息
  const initializeStockInfo = async () => {
    try {
      await stockInfoApi.initializeStockInfo();
      fetchStockInfo();
    } catch (error) {
      console.error('初始化股票信息失败:', error);
    }
  };

  // 添加或更新股票信息
  const handleSaveStockInfo = async () => {
    try {
      const values = await stockInfoForm.validateFields();
      
      // 确保类型是数字
      values.type = parseInt(values.type, 10);
      
      if (editingStock) {
        // 更新
        await stockInfoApi.updateStockInfo(editingStock.code, values);
      } else {
        // 添加
        await stockInfoApi.addStockInfo(values);
      }
      
      setModalVisible(false);
      stockInfoForm.resetFields();
      setEditingStock(null);
      fetchStockInfo();
    } catch (error) {
      console.error('保存股票信息失败:', error);
    }
  };

  // 删除股票信息
  const handleDeleteStockInfo = async (code) => {
    try {
      await stockInfoApi.deleteStockInfo(code);
      fetchStockInfo();
    } catch (error) {
      console.error('删除股票信息失败:', error);
    }
  };

  // 编辑股票信息
  const handleEditStockInfo = (record) => {
    setEditingStock(record);
    stockInfoForm.setFieldsValue({
      code: record.code,
      name: record.name,
      type: record.type.toString(),
      can_trade: record.can_trade === "1" ? "1" : "0"
    });
    setModalVisible(true);
  };

  // 添加新股票
  const handleAddStockInfo = () => {
    setEditingStock(null);
    stockInfoForm.resetFields();
    setModalVisible(true);
  };

  // 股票信息表格列定义
  const stockInfoColumns = [
    {
      title: '代码',
      dataIndex: 'code',
      key: 'code',
      sorter: (a, b) => a.code.localeCompare(b.code)
    },
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
      sorter: (a, b) => a.name.localeCompare(b.name)
    },
    {
      title: '类型',
      dataIndex: 'type',
      key: 'type',
      render: (type) => type === 1 ? '指数' : '行业',
      filters: [
        { text: '指数', value: 1 },
        { text: '行业', value: 2 }
      ],
      onFilter: (value, record) => record.type === value
    },
    {
      title: '可交易',
      dataIndex: 'can_trade',
      key: 'can_trade',
      render: (can_trade) => can_trade === "1" ? '是' : '否',
      filters: [
        { text: '是', value: "1" },
        { text: '否', value: "0" }
      ],
      onFilter: (value, record) => record.can_trade === value
    },
    {
      title: '操作',
      key: 'action',
      render: (_, record) => (
        <Space size="middle">
          <Button type="link" icon={<EditOutlined />} onClick={() => handleEditStockInfo(record)}>
            编辑
          </Button>
          <Popconfirm
            title="确定要删除这个股票信息吗?"
            onConfirm={() => handleDeleteStockInfo(record.code)}
            okText="确定"
            cancelText="取消"
          >
            <Button type="link" danger icon={<DeleteOutlined />}>
              删除
            </Button>
          </Popconfirm>
        </Space>
      )
    }
  ];

  // 切换标签页时加载数据
  const handleTabChange = (activeKey) => {
    if (activeKey === 'stockInfo' && stockList.length === 0) {
      fetchStockInfo();
    }
  };

  // 股票信息分页变化处理函数
  const handleStockInfoPageChange = (page, pageSize) => {
    setStockInfoPagination({
      ...stockInfoPagination,
      current: page,
      pageSize: pageSize
    });
  };

  // 获取当前页的股票信息数据
  const getCurrentPageData = () => {
    const { current, pageSize } = stockInfoPagination;
    const startIndex = (current - 1) * pageSize;
    const endIndex = startIndex + pageSize;
    return stockList.slice(startIndex, endIndex);
  };

  const fetchIntegrityData = async (isReal = integrityIsReal, startDate = integrityStartDate) => {
    setIntegrityLoading(true);
    try {
      const data = await stockDataIntegrityApi.checkIntegrity(isReal, startDate ? startDate.format('YYYY-MM-DD HH:mm:ss') : null);
      setIntegrityData(data);
    } catch (e) {
      setIntegrityData({ missing: [], duplicate: [], base_code: '', base_dates_count: 0 });
    } finally {
      setIntegrityLoading(false);
    }
  };

  useEffect(() => {
    fetchIntegrityData(integrityIsReal, integrityStartDate);
    // eslint-disable-next-line
  }, [integrityIsReal, integrityStartDate]);

  // 工具函数：按code分组
  const groupByCode = (arr) => {
    const map = {};
    arr.forEach(item => {
      if (!map[item.code]) map[item.code] = [];
      map[item.code].push(item);
    });
    return map;
  };

  const handleSync = async () => {
    if (!syncDate) {
      Modal.warning({ title: '请选择同步起始日期' });
      return;
    }
    setSyncLoading(true);
    setSyncResult(null);
    try {
      const res = await sync5mToRealgo5mApi.sync(syncDate.format('YYYY-MM-DD HH:mm:ss'));
      setSyncResult(res.result || []);
    } catch (e) {
      Modal.error({ title: '同步失败', content: e?.error || e?.message || '未知错误' });
    } finally {
      setSyncLoading(false);
    }
  };

  return (
    <div className="stock-data-page">
      <Row gutter={[24, 24]}>
        <Col span={24}>
          <Tabs defaultActiveKey="dataQuery" onChange={handleTabChange}>
            <TabPane tab="数据查询" key="dataQuery">
              <div className="sticky-form-container">
                <Card bordered={false} className="sticky-form-card">
                  <Form
                    form={form}
                    layout="horizontal"
                    onFinish={handleSubmit}
                    initialValues={{
                      is_real: false,
                      page_size: 100
                    }}
                  >
                    <Row gutter={24}>
                      <Col xs={24} sm={8} md={6}>
                        <Form.Item
                          label="数据源"
                          name="is_real"
                          rules={[{ required: true, message: '请选择数据源' }]}
                        >
                          <Radio.Group onChange={handleDataSourceChange}>
                            <Radio value={false}>历史数据</Radio>
                            <Radio value={true}>实盘数据</Radio>
                          </Radio.Group>
                        </Form.Item>
                      </Col>
                      
                      <Col xs={24} sm={16} md={10}>
                        <Form.Item
                          label="股票代码"
                          name="code"
                          rules={[{ required: true, message: '请选择股票代码' }]}
                        >
                          <Select
                            showSearch
                            placeholder="选择股票代码"
                            optionFilterProp="children"
                            style={{ width: '100%' }}
                          >
                            {form.getFieldValue('is_real') 
                              ? (availableCodes.real || []).map(code => (
                                  <Option key={code} value={code}>{code}</Option>
                                ))
                              : (availableCodes.history || []).map(code => (
                                  <Option key={code} value={code}>{code}</Option>
                                ))
                            }
                          </Select>
                        </Form.Item>
                      </Col>
                      
                      <Col xs={24} sm={12} md={8}>
                        <Form.Item
                          label="日期范围"
                          name="dateRange"
                        >
                          <RangePicker 
                            showTime={{ format: 'HH:mm:ss' }}
                            format="YYYY-MM-DD HH:mm:ss"
                            style={{ width: '100%' }}
                          />
                        </Form.Item>
                      </Col>
                      
                      <Col xs={24} sm={12} md={6}>
                        <Form.Item
                          label="每页记录数"
                          name="page_size"
                          rules={[{ required: true, message: '请选择每页记录数' }]}
                        >
                          <Select style={{ width: '100%' }}>
                            <Option value={50}>50条/页</Option>
                            <Option value={100}>100条/页</Option>
                            <Option value={200}>200条/页</Option>
                            <Option value={500}>500条/页</Option>
                          </Select>
                        </Form.Item>
                      </Col>
                      
                      <Col xs={24} sm={24} md={6}>
                        <Form.Item wrapperCol={{ sm: { offset: 0 }, md: { offset: 8 } }}>
                          <Button
                            type="primary"
                            htmlType="submit"
                            loading={loading}
                            icon={<SearchOutlined />}
                            style={{ marginTop: 4 }}
                          >
                            查询
                          </Button>
                        </Form.Item>
                      </Col>
                    </Row>
                  </Form>
                </Card>
              </div>
              
              <div className="data-content">
                {error && <Alert message={error} type="error" showIcon style={{ marginBottom: 16 }} />}
                
                {stockData && stockData.data && stockData.data.length > 0 ? (
                  <div className="data-results">
                    <div className="data-results-header">
                      <Title level={4}>
                        {queryParams.is_real ? '实盘' : '历史'}数据: {stockData.code}
                      </Title>
                      
                      <Text type="secondary">
                        共 {stockData.pagination.total_records} 条记录
                      </Text>
                    </div>
                    
                    <Table
                      columns={generateColumns()}
                      dataSource={stockData.data.map((item, index) => ({ ...item, key: index }))}
                      pagination={false}
                      scroll={{ x: 'max-content' }}
                      loading={loading}
                      size="middle"
                    />
                    
                    <div className="pagination-container">
                      <Pagination
                        current={queryParams.page}
                        pageSize={queryParams.page_size}
                        total={stockData.pagination.total_records}
                        onChange={handlePageChange}
                        onShowSizeChange={(current, size) => handlePageChange(current, size)}
                        showSizeChanger
                        showQuickJumper
                        showTotal={(total) => `共 ${total} 条记录`}
                      />
                    </div>
                  </div>
                ) : !loading && (
                  <div className="data-placeholder">
                    <DatabaseOutlined style={{ fontSize: 64, color: '#ccc' }} />
                    <Text type="secondary">请选择股票代码并点击查询</Text>
                  </div>
                )}
              </div>
            </TabPane>
            
            <TabPane tab="股票信息管理" key="stockInfo">
              <div className="sticky-form-container">
                <Card bordered={false} className="sticky-form-card">
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
                    <Title level={4} style={{ margin: 0 }}>股票信息管理</Title>
                    <Space>
                      <Button 
                        type="primary" 
                        icon={<PlusOutlined />} 
                        onClick={handleAddStockInfo}
                      >
                        添加股票
                      </Button>
                      <Button 
                        icon={<ReloadOutlined />} 
                        onClick={fetchStockInfo}
                      >
                        刷新
                      </Button>
                      <Popconfirm
                        title="确定要初始化股票信息吗? 这将覆盖现有数据。"
                        onConfirm={initializeStockInfo}
                        okText="确定"
                        cancelText="取消"
                      >
                        <Button>初始化数据</Button>
                      </Popconfirm>
                    </Space>
                  </div>
                </Card>
              </div>
              
              <div className="data-content">
                <Table
                  columns={stockInfoColumns}
                  dataSource={getCurrentPageData()}
                  rowKey="code"
                  loading={stockInfoLoading}
                  pagination={false}
                />
              </div>
            </TabPane>
            <TabPane tab="数据完整性" key="integrity">
              <ConfigProvider locale={zhCN}>
                <Card bordered={false} style={{ marginBottom: 16 }}>
                  <Space style={{ marginBottom: 16 }}>
                    <Radio.Group
                      value={integrityIsReal}
                      onChange={e => {
                        setIntegrityIsReal(e.target.value);
                        setIntegrityTab('missing');
                        setIntegrityPage(1);
                        setIntegrityMissingPageMap({});
                        setIntegrityDuplicatePageMap({});
                      }}
                    >
                      <Radio.Button value={true}>实盘数据</Radio.Button>
                      <Radio.Button value={false}>历史数据</Radio.Button>
                    </Radio.Group>
                    <DatePicker
                      showTime
                      allowClear
                      value={integrityStartDate}
                      onChange={date => {
                        setIntegrityStartDate(date);
                        setIntegrityTab('missing');
                        setIntegrityPage(1);
                        setIntegrityMissingPageMap({});
                        setIntegrityDuplicatePageMap({});
                      }}
                      placeholder="起始日期（可选）"
                      style={{ width: 200 }}
                    />
                    <Button type="primary" loading={integrityLoading} onClick={() => fetchIntegrityData(integrityIsReal, integrityStartDate)}>
                      查询数据完整性
                    </Button>
                  </Space>
                  <Divider />
                  <div>
                    <b>基准股票：</b>{integrityData.base_code}，基准日期数：{integrityData.base_dates_count}
                    {integrityData.start_date && (
                      <span style={{ marginLeft: 16 }}><b>起始日期：</b>{integrityData.start_date}</span>
                    )}
                  </div>
                  <Tabs activeKey={integrityTab} onChange={setIntegrityTab} style={{ marginTop: 16 }}>
                    <TabPane tab={`缺失数据（${integrityData.missing.length}）`} key="missing">
                      <Collapse accordion>
                        {Object.entries(groupByCode(integrityData.missing)).map(([code, items]) => {
                          const page = integrityMissingPageMap[code] || 1;
                          const total = items.length;
                          const pagedItems = items.slice((page-1)*PAGE_SIZE, page*PAGE_SIZE);
                          return (
                            <Collapse.Panel header={`${code}（${items.length}条）`} key={code}>
                              <Table
                                columns={[{ title: '日期', dataIndex: 'date', key: 'date' }]}
                                dataSource={pagedItems.map((item, idx) => ({ ...item, key: idx }))}
                                pagination={false}
                                size="small"
                              />
                              <Pagination
                                current={page}
                                pageSize={PAGE_SIZE}
                                total={total}
                                onChange={p => setIntegrityMissingPageMap(prev => ({ ...prev, [code]: p }))}
                                style={{ marginTop: 8 }}
                              />
                            </Collapse.Panel>
                          );
                        })}
                      </Collapse>
                      <div style={{marginTop: 16, color: '#888'}}>共 {Object.keys(groupByCode(integrityData.missing)).length} 个股票代码</div>
                    </TabPane>
                    <TabPane tab={`重复数据（${integrityData.duplicate.length}）`} key="duplicate">
                      <Collapse accordion>
                        {Object.entries(groupByCode(integrityData.duplicate)).map(([code, items]) => {
                          const page = integrityDuplicatePageMap[code] || 1;
                          const total = items.length;
                          const pagedItems = items.slice((page-1)*PAGE_SIZE, page*PAGE_SIZE);
                          return (
                            <Collapse.Panel header={`${code}（${items.length}条）`} key={code}>
                              <Table
                                columns={[
                                  { title: '日期', dataIndex: 'date', key: 'date' },
                                  { title: '重复数', dataIndex: 'count', key: 'count' }
                                ]}
                                dataSource={pagedItems.map((item, idx) => ({ ...item, key: idx }))}
                                pagination={false}
                                size="small"
                              />
                              <Pagination
                                current={page}
                                pageSize={PAGE_SIZE}
                                total={total}
                                onChange={p => setIntegrityDuplicatePageMap(prev => ({ ...prev, [code]: p }))}
                                style={{ marginTop: 8 }}
                              />
                            </Collapse.Panel>
                          );
                        })}
                      </Collapse>
                      <div style={{marginTop: 16, color: '#888'}}>共 {Object.keys(groupByCode(integrityData.duplicate)).length} 个股票代码</div>
                    </TabPane>
                  </Tabs>
                </Card>
              </ConfigProvider>
            </TabPane>
            <TabPane tab="数据同步" key="sync">
              <ConfigProvider locale={zhCN}>
                <Card bordered={false} style={{ marginBottom: 16 }}>
                  <Space>
                    <DatePicker
                      showTime
                      allowClear={false}
                      value={syncDate}
                      onChange={setSyncDate}
                      placeholder="请选择同步起始日期"
                      style={{ width: 220 }}
                    />
                    <Button type="primary" loading={syncLoading} onClick={handleSync}>
                      开始同步
                    </Button>
                  </Space>
                  <Divider />
                  {syncResult && (
                    <Table
                      columns={[
                        { title: '股票代码', dataIndex: 'code', key: 'code' },
                        { title: '新增条数', dataIndex: 'added', key: 'added' },
                        { title: '同步后总数', dataIndex: 'total', key: 'total' },
                        { title: '错误', dataIndex: 'error', key: 'error', render: v => v || '-' }
                      ]}
                      dataSource={syncResult.map((item, idx) => ({ ...item, key: idx }))}
                      pagination={{ pageSize: 100 }}
                      size="small"
                    />
                  )}
                </Card>
              </ConfigProvider>
            </TabPane>
          </Tabs>
          
          {/* 添加/编辑股票的表单弹窗 */}
          <Modal
            title={editingStock ? '编辑股票信息' : '添加股票信息'}
            open={modalVisible}
            onOk={handleSaveStockInfo}
            onCancel={() => {
              setModalVisible(false);
              stockInfoForm.resetFields();
            }}
            maskClosable={true}
            okText="保存"
            cancelText="取消"
          >
            <Form
              form={stockInfoForm}
              layout="vertical"
            >
              <Form.Item
                name="code"
                label="股票代码"
                rules={[
                  { required: true, message: '请输入股票代码' },
                  { pattern: /^[0-9]+\.[A-Z]+$/, message: '股票代码格式应为: 数字.交易所代码' }
                ]}
                disabled={!!editingStock}
              >
                <Input placeholder="例如: 000300.XSHG" disabled={!!editingStock} />
              </Form.Item>
              
              <Form.Item
                name="name"
                label="股票名称"
                rules={[{ required: true, message: '请输入股票名称' }]}
              >
                <Input placeholder="例如: 沪深300" />
              </Form.Item>
              
              <Form.Item
                name="type"
                label="类型"
                rules={[{ required: true, message: '请选择类型' }]}
              >
                <Select placeholder="请选择类型">
                  <Option value="1">指数</Option>
                  <Option value="2">行业</Option>
                </Select>
              </Form.Item>
              
              <Form.Item
                name="can_trade"
                label="可交易"
                rules={[{ required: true, message: '请选择是否可交易' }]}
              >
                <Select placeholder="请选择是否可交易">
                  <Option value="1">是</Option>
                  <Option value="0">否</Option>
                </Select>
              </Form.Item>
            </Form>
          </Modal>
        </Col>
      </Row>
    </div>
  );
};

export default StockData; 